
#include <reg52.h>

sbit LED1=P2^0;
sbit LED1=P2^1;

static unsigned char chishu,result;
unsigned char t_40s,count;

void Timer0_Init()
{
    TMOD|=0X01; //配置了低4位，选择定时器0模式，工作方式1，仅用TR0打开启动
    TH0=0XFC; //给定时器赋初值，定时1ms
    TLO=0X18; //给定时器赋初值，定时1ms
    ET0=1;  //打开定时器0中断允许，在IE寄存器里面
    EA=1; //打开总中断，也是在IE寄存器里面
    TR0=1; //打开定时器
}


int run()
{
    t_40s+=flag_1s;
    LED1=1;
    if(t_40s==20)
    {
        chishu++;
    }
    if(t_40s==40)
    {
       t_40s=0;
       LED1=0;
       return 233;
    }

    if(key==1)
    {
        t_40s=0;
        return 233;
    }

    return 233;


}

int main()
{
    Timer0_Init();
    while(1)
    {
        if(key==1)
        {
            run();
        }
        
        
    }
    
 
    return 0;
}

void Timer0() interrupt 1
{
    static unsigned char flag_1s=0,flag_1min=0,count;
    static unsigned int t_1s,t_min;
    TH0=0XFC;
    TL0=0X18;
    i++;
    if(i==1000)
    {
        i=0;
        flag_1s=1;
        t_min++;
        if(t_min==60)
        {
            num=0;
            flag_1min=1;
        }
    }

    if(chushu==5&&(result=run())==233)
    {
        LED1=0;
        LED2=1;
        count+=flag_1min；
        if(count==10)
        {
            chushu=0;
            count=0;
        }
        
        
    
    }

}